package com.bort.system.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.math.BigDecimal;
import java.util.Date;

@Data
@TableName("user")
public class User {

    @TableId("id")
    protected Integer id;

    @TableField("name")
    protected String name;

    @TableField("username")
    protected String username;

    @TableField("type")
    protected Byte type;

    @TableField("password")
    protected String password;

    @TableField("phone")
    protected String phone;

    @TableField("avatar")
    protected String avatar;

    @TableField("create_time")
    protected Date createTime;

    @TableField("gender")
    protected Byte gender;

    @TableField("status")
    protected Byte status;

    @TableField("unionId")
    protected String unionid;

    @TableField("charge")
    private BigDecimal charge;

    @TableField("extra")
    private BigDecimal extra;

    @TableField("balance")
    private BigDecimal balance;

    @TableField("create_user_id")
    private Integer createUserId;

    @TableField("access_token")
    private String accessToken;

    @TableField(exist = false)
    protected String createTimeStr;

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
        this.createTimeStr = DateFormatUtils.format(createTime,"yyyy-MM-dd HH:mm:ss");
    }
}
